package le.ralph.quwen.cn.java.utils;

import le.ralph.quwen.cn.java.view.QuWenApplication;

public class UiUtil {

    public static int px2dp(float pxValue) {
        final float scale = QuWenApplication.getContext().getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }


    /**
     * convert dp to its equivalent px
     * <p>
     * 将dp转换为与之相等的px
     */
    public static int dp2px(float dipValue) {
        final float scale = QuWenApplication.getContext().getResources().getDisplayMetrics().density;
        return (int) (dipValue * scale + 0.5f);
    }
}
